<template>
  <div class="home">
    <div class="bgLogin">
      <img src="../assets/images/登录页-1.jpg" width="100%"  height="100%" alt=""/>
      <div class="pwdName">
        <van-form>
          <van-field v-model="username" label="账户"/>
          
          <van-field
            v-model="password" type="password" label="密码"/>
          <div style="margin:16px">
            <van-button round block type="info" @click="btn">点击登录</van-button>
          </div>
        </van-form>
        
      </div>
    </div>
  </div>
</template>

<script>
import {login} from '../request/api'
export default {
  data(){
    return{
        username: '13133593288',
        password: '123456',
    }
  },
  methods: {
    btn() {
        if(this.username.length==0 && this.password.length==0){
            this.$toast('账号或密码不能为空!');
            return;
        }
        login({
            "username":this.username,
            "password":this.password
        }).then(res=>{  

          if(!res.errCode){
            this.username="";
            this.password="";
            localStorage.setItem("token",res.data)
             this.$router.push("/home/funindex");          
          }         
            
        })
     
    },
  },
};
</script>
<style lang="less" scoped>
.bgLogin{
  position: relative;
  .pwdName{
    position: absolute;
    bottom: 110px;
    left: 69px;

    .van-cell{
      border: 1px solid #000;
      border-radius: 25px;
      background: orange;
      margin-bottom: 15px;
      /deep/.van-field__label{
        width: 30px;
        font-weight: bold;
        color: #000;
      }
    }
    
  }
}
</style>
